#!/usr/bin/env jruby
# -*- ruby -*-
#. hashdot.profile         += daemon
#. hashdot.pid_file         = ./rjack-zookeeper.pid
#. hashdot.io_redirect.file = ./rjack-zookeeper.log
#. hashdot.vm.options += -Xmx1g
#. hashdot.vm.options += -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled

#--
# Copyright (c) 2011-2016 David Kellum
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License.  You
# may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.  See the License for the specific language governing
# permissions and limitations under the License.
#++

$LOAD_PATH.unshift File.join( File.dirname(__FILE__), "..", "lib" )

require 'rubygems'
gem( "rjack-zookeeper", "= 3.4.5.0" )

module BinScript
  require 'rjack-zookeeper/base'
  require 'rjack-slf4j/log4j-over-slf4j'
  require 'rjack-logback'

  include RJack
  Logback.config_console( :full => true, :thread => true )
  Logback[ 'org.apache.zookeeper' ].level = :warn

  require 'java'

  # Disable log4j JMX registrations unless already set (i.e. false).
  # Otherwise can fail with NoClassDefFoundError:
  #   o.a.log4j.jmx.HierarchyDynamicMBean
  Java::java.lang.System.properties[ 'zookeeper.jmx.log4j.disable' ] ||= 'true'

  require 'rjack-zookeeper'
  Logback[ 'org.apache.zookeeper' ].level = nil

  RZooKeeper::QuorumPeerMain::main( [ 'zoo.cfg' ] )
end
